<?php
/**
 * @copyright  For copyright and license information, read the COPYING.txt file.
 * @link       /COPYING.txt
 * @license    Academic Free License (AFL 3.0)
 * @package     default_default
 */

/** @var Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content $this */
?>
<div id="<?php echo $this->getHtmlId() ?>">
    <ul class="messages">
        <li class="notice-msg">
            <ul>
                <li>
                    <?php echo Mage::helper('catalog')->__('Image type and information need to be specified for each store view.'); ?>
                </li>
            </ul>
        </li>
    </ul>
    <div class="grid">
        <table cellspacing="0" class="data border" id="<?php echo $this->getHtmlId() ?>_grid" width="100%">
            <col width="1"/>
            <col/>
            <col width="70"/>
            <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                <col/>
            <?php endforeach ?>
            <col width="70"/>
            <col width="70"/>
            <thead>
            <tr class="headings">
                <th><?php echo Mage::helper('catalog')->__('Image') ?></th>
                <th><?php echo Mage::helper('catalog')->__('Label') ?></th>
                <th><?php echo Mage::helper('catalog')->__('Sort Order') ?></th>
                <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                    <th><?php echo $this->escapeHtml($type['label'], ['br']); ?></th>
                <?php endforeach ?>
                <th><?php echo Mage::helper('catalog')->__('Exclude') ?></th>
                <th class="last"><?php echo Mage::helper('catalog')->__('Remove') ?></th>
            </tr>
            </thead>
            <tbody id="<?php echo $this->getHtmlId() ?>_list">
            <tr id="<?php echo $this->getHtmlId() ?>_template" class="template no-display">
                <td class="cell-image">
                    <div class="place-holder"
                         onmouseover="<?php echo $this->getJsObjectName(); ?>.loadImage('__file__')">
                        <span><?php echo Mage::helper('catalog')->__('Roll Over for preview') ?></span></div>
                    <img src="<?php echo $this->getSkinUrl('images/spacer.gif') ?>" width="100" style="display:none;"
                         alt=""/></td>
                <td class="cell-label"><input
                            type="text" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            class="input-text"
                            onkeyup="<?php echo $this->getJsObjectName(); ?>.updateImage('__file__')"
                            onchange="<?php echo $this->getJsObjectName(); ?>.updateImage('__file__')"/></td>
                <td class="cell-position"><input
                            type="text" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            class="input-text validate-number"
                            onkeyup="<?php echo $this->getJsObjectName(); ?>.updateImage('__file__')"
                            onchange="<?php echo $this->getJsObjectName(); ?>.updateImage('__file__')"/></td>
                <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                    <td class="cell-<?php echo $typeId ?> a-center">
                        <input <?php if ($this->getElement()->getAttributeReadonly($typeId)) : ?> disabled="disabled" <?php endif ?>
                                type="radio" name="<?php echo $type['field'] ?>"
                                onclick="<?php echo $this->getJsObjectName(); ?>.setProductImages('__file__')"
                                value="__file__"/></td>
                <?php endforeach ?>
                <td class="cell-disable a-center"><input
                            type="checkbox" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            onclick="<?php echo $this->getJsObjectName(); ?>.updateImage('__file__')"/></td>
                <td class="cell-remove a-center last"><input
                            type="checkbox" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            onclick="<?php echo $this->getJsObjectName(); ?>.updateImage('__file__')"/></td>
            </tr>
            <?php if ($this->hasUseDefault()): ?>
                <tr id="<?php echo $this->getHtmlId() ?>_default">
                    <td><?php echo Mage::helper('catalog')->__('Use Default Value') ?></td>
                    <td class="a-center">
                        <input id="use_default_label" class="default-checkbox" name="use_default[]" type="checkbox"
                            <?php if ($this->getElement()->getAttributeReadonly("label")): ?> disabled="disabled" <?php endif ?>
                               onclick="<?php echo $this->getJsObjectName(); ?>.updateUseDefault(this)"
                               <?php if ($this->getElement()->usedDefault("label")): ?>checked<?php endif ?>
                               value="label"/>
                    </td>
                    <td>
                        <input id="use_default_position" class="default-checkbox" name="use_default[]" type="checkbox"
                            <?php if ($this->getElement()->getAttributeReadonly("position")): ?> disabled="disabled" <?php endif ?>
                               onclick="<?php echo $this->getJsObjectName(); ?>.updateUseDefault(this)"
                               <?php if ($this->getElement()->usedDefault("position")): ?>checked<?php endif ?>
                               value="position"/>
                    </td>
                    <?php foreach ($this->getMediaAttributes() as $_attribute): ?>
                        <td class="a-center">
                            <?php if ($this->getElement()->canDisplayUseDefault($_attribute)): ?>
                                <input class="default-checkbox" name="use_default[]"
                                       type="checkbox" <?php if ($this->getElement()->getAttributeReadonly($_attribute->getAttributeCode())): ?> disabled="disabled" <?php endif ?>
                                       onclick="<?php echo $this->getJsObjectName(); ?>.updateUseDefault()"
                                       <?php if ($this->getElement()->usedDefault($_attribute)): ?>checked<?php endif ?>
                                       value="<?php echo $_attribute->getAttributeCode() ?>"/>
                            <?php endif ?>
                        </td>
                    <?php endforeach ?>
                    <td>&nbsp;</td>
                    <td class="last">&nbsp;</td>
                </tr>
            <?php endif ?>
            <tr id="<?php echo $this->getHtmlId() ?>-image-0">
                <td class="cell-image"><?php echo Mage::helper('catalog')->__('No image') ?></td>
                <td class="cell-label"><input type="hidden"/>&nbsp;</td>
                <td class="cell-position"><input type="hidden"/>&nbsp;</td>
                <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                    <td class="cell-<?php echo $typeId ?> a-center"><input
                                type="radio" <?php if ($this->getElement()->getAttributeReadonly($typeId)) : ?> disabled="disabled" <?php endif ?>
                                name="<?php echo $type['field'] ?>"
                                onclick="<?php echo $this->getJsObjectName(); ?>.setProductImages('no_selection')"
                                value="no_selection"/></td>
                <?php endforeach ?>
                <td class="cell-disable"><input type="hidden"/>&nbsp;</td>
                <td class="cell-remove last"><input type="hidden"/>&nbsp;</td>
            </tr>
            </tbody>
            <?php if (!$this->getElement()->getReadonly()): ?>
                <tfoot>
                <tr>
                    <td colspan="100" class="last" style="padding:8px">
                        <?php echo Mage::helper('catalog')->__('Maximum width and height dimension for upload image is %s.', Mage::getStoreConfig(Mage_Catalog_Helper_Image::XML_NODE_PRODUCT_MAX_DIMENSION)); ?>
                        <?php echo $this->getUploaderHtml() ?>
                    </td>
                </tr>
                </tfoot>
            <?php endif ?>
        </table>
    </div>
</div>
<input type="hidden" id="<?php echo $this->getHtmlId() ?>_save"
       name="<?php echo $this->getElement()->getName() ?>[images]"
       value="<?php echo $this->escapeHtml($this->getImagesJson()) ?>"/>
<input type="hidden" id="<?php echo $this->getHtmlId() ?>_save_image"
       name="<?php echo $this->getElement()->getName() ?>[values]"
       value="<?php echo $this->escapeHtml($this->getImagesValuesJson()) ?>"/>
<script type="text/javascript">
//<![CDATA[
var <?php echo $this->getJsObjectName(); ?> = new Product.Gallery('<?php echo $this->getHtmlId() ?>', <?php echo $this->getImageTypesJson() ?>);
//]]>
</script>
